//
//  AddSectionController.m
//  NewsReader
//
//  Created by blacksun on 10-10-30.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "AddSectionController.h"


@implementation AddSectionController

@synthesize listController,imageView,subcribeController,subcribeButton;

#pragma mark -
#pragma mark View lifecycle

-(IBAction)wantToAddSection:(id)sender{
	if (![HttpUtil isNetworkUseable]) {
		[HttpUtil showUsageAlertDialog];
		return;
	}
	NewsReaderAppDelegate *delegate = [UIApplication sharedApplication].delegate;
	
	if ([delegate.user.userId length] == 0 || [delegate.user.userId isEqualToString:kUser_defaultUserId]){
		NSString *message = @"网络问题造成初始化失败，请退出软件，稍后再试";
		UIAlertView *usageAlertView = [[UIAlertView alloc] initWithTitle:@"提示" message:message delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
		[usageAlertView show];
		
	}
	SubcribeSectionController *controller = [[SubcribeSectionController alloc] initWithNibName:@"SubcribeSectionController" bundle:nil];
	controller.title = @"添加订阅";
	self.subcribeController = controller;
	[controller release];
	[delegate.navigationController pushViewController:self.subcribeController animated:YES];
}

- (void)needToDeleteMySelf{
	self.subcribeButton.hidden = YES;
}
- (void)resumeNormal{
	self.subcribeButton.hidden = NO;
}
- (void)viewDidLoad {
    [super viewDidLoad];
	AddSectionListController *addSectionList = [[AddSectionListController alloc] initWithNibName:@"AddSectionListController" bundle:nil];
	self.listController = addSectionList;
	self.listController.view.frame = CGRectMake(20.0, 74.0, 280.0, 390.0);
	[addSectionList release];
	self.view.alpha = 0.2;
	[UIView beginAnimations:nil context:nil];
	[UIView setAnimationDuration:2.0];
	[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
	self.view.alpha = 1.0;
	[UIView commitAnimations];
	
	
	//给图片加圆角
	self.imageView.layer.cornerRadius = 6;
	self.imageView.layer.masksToBounds = YES;
}


/*
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
}
*/
/*
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
}
*/
/*
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
}
*/
/*
- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
}
*/
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/




#pragma mark -
#pragma mark Memory management

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Relinquish ownership any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
    // For example: self.myOutlet = nil;
}


- (void)dealloc {
	[self.subcribeController release];
	[self.imageView release];
	[listController release];
	[self.subcribeButton release];
    [super dealloc];
}


@end

